package com.yssw.config;

import fr.opensagres.poi.xwpf.converter.core.ImageManager;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.io.*;

/**
 * @Author KnockingFarmers
 * @Date 2023/3/31 15:03
 * @PackageName:com.yssw.config
 * @ClassName: UtilBeanConfig
 * @Description: TODO
 * @Version 1.0
 */
@Slf4j
@Component
public class ImageManagerImpl extends ImageManager {


        private static final String localFilePath="C:/Users/Administrator/Desktop/project/uploadFile/upload/newsImg";
//    private static final String localFilePath="D:/yssw/uploadPath/newsImg";
//    private static final String imagePath="D:/yssw/uploadPath/newsImg";
    private static final String imagePath="http://43.139.225.101/prod-api/profile/upload/newsImg";

    public ImageManagerImpl() {
        super(new File(localFilePath), "");

    }



    @Override
    public void extract(String imagePath, byte[] imageData) throws IOException {
       super.extract(imagePath,imageData);

    }

    @SneakyThrows
    @Override
    public String resolve(String uri) {
        StringBuilder builder=new StringBuilder(uri);
        int last = builder.lastIndexOf("/");
        String substring = builder.substring(last, builder.length());


        return imagePath+substring;
    }
}
